﻿using SqlSugar;

namespace DataAcquisitionDAL
{/// <summary>
 /// 试压模板
 ///</summary>
    [SugarTable("d_template")]
    public class TemplateModel
    {
        /// <summary>
        /// 备  注:ID
        ///</summary>
        [SugarColumn(ColumnName = "id", IsPrimaryKey = true, IsIdentity = true)]
        public int ID { get; set; }

        /// <summary>
        /// 备  注:编号
        ///</summary>
        [SugarColumn(ColumnName = "number", IsPrimaryKey = true)]
        public int Number { get; set; }

        /// <summary>
        /// 备  注:管道位置
        ///</summary>
        [SugarColumn(ColumnName = "pipe_position")]
        public string PipePosition { get; set; } = null!;

        /// <summary>
        /// 备  注:设计压力
        ///</summary>
        [SugarColumn(ColumnName = "design_pressure")]
        public double DesignPressure { get; set; }

        //-----------------------------------------------------------------

        /// <summary>
        /// 备  注:阶段一压力
        ///</summary>
        [SugarColumn(ColumnName = "first_stage_pressure")]
        public double FirstStagePressure { get; set; }

        /// <summary>
        /// 备  注:阶段一持续时间
        ///</summary>
        [SugarColumn(ColumnName = "first_stage_time")]
        public int FirstStageTime { get; set; }

        /// <summary>
        /// 备  注:阶段一持续时间单位：小时、分钟
        ///</summary>
        [SugarColumn(ColumnName = "first_stage_time_unit")]
        public string FirstStageTimeUnit { get; set; } = null!;

        /// <summary>
        /// 备  注:阶段一判断方式 0：固定数值 1：浮动范围
        ///</summary>
        [SugarColumn(ColumnName = "first_stage_estimate_way")]
        public int FirstStageEstimateWay { get; set; }

        /// <summary>
        /// 备  注:阶段一判断值
        ///</summary>
        [SugarColumn(ColumnName = "first_stage_estimate_value")]
        public double FirstStageEstimateValue { get; set; }

        //-----------------------------------------------------------------

        /// <summary>
        /// 备  注:阶段二压力
        ///</summary>
        [SugarColumn(ColumnName = "second_stage_pressure")]
        public double SecondStagePressure { get; set; }

        /// <summary>
        /// 备  注:阶段二持续时间
        ///</summary>
        [SugarColumn(ColumnName = "second_stage_time")]
        public int SecondStageTime { get; set; }

        /// <summary>
        /// 备  注:阶段二持续时间单位：小时、分钟
        ///</summary>
        [SugarColumn(ColumnName = "second_stage_time_unit")]
        public string SecondStageTimeUnit { get; set; } = null!;

        /// <summary>
        /// 备  注:阶段二判断方式 0：固定数值 1：浮动范围
        ///</summary>
        [SugarColumn(ColumnName = "second_stage_estimate_way")]
        public int SecondStageEstimateWay { get; set; }

        /// <summary>
        /// 备  注:阶段二判断值
        ///</summary>
        [SugarColumn(ColumnName = "second_stage_estimate_value")]
        public double SecondStageEstimateValue { get; set; }

        //-----------------------------------------------------------------

        /// <summary>
        /// 备  注:阶段三压力
        ///</summary>
        [SugarColumn(ColumnName = "third_stage_pressure")]
        public double ThirdStagePressure { get; set; }

        /// <summary>
        /// 备  注:阶段三持续时间
        ///</summary>
        [SugarColumn(ColumnName = "third_stage_time")]
        public int ThirdStageTime { get; set; }

        /// <summary>
        /// 备  注:阶段三持续时间单位：小时、分钟
        ///</summary>
        [SugarColumn(ColumnName = "third_stage_time_unit")]
        public string ThirdStageTimeUnit { get; set; } = null!;

        /// <summary>
        /// 备  注:阶段三判断方式 0：固定数值 1：浮动范围
        ///</summary>
        [SugarColumn(ColumnName = "third_stage_estimate_way")]
        public int ThirdStageEstimateWay { get; set; }

        /// <summary>
        /// 备  注:阶段三判断值
        ///</summary>
        [SugarColumn(ColumnName = "third_stage_estimate_value")]
        public double ThirdStageEstimateValue { get; set; }

        //-----------------------------------------------------------------

        /// <summary>
        /// 备  注:强度阶段压力
        ///</summary>
        [SugarColumn(ColumnName = "intensity_stage_pressure")]
        public double IntensityStagePressure { get; set; }

        /// <summary>
        /// 备  注:强度阶段持续时间
        ///</summary>
        [SugarColumn(ColumnName = "intensity_stage_time")]
        public int IntensityStageTime { get; set; }

        /// <summary>
        /// 备  注:强度阶段持续时间单位：小时、分钟
        ///</summary>
        [SugarColumn(ColumnName = "intensity_stage_time_unit")]
        public string IntensityStageTimeUnit { get; set; } = null!;

        /// <summary>
        /// 备  注:强度阶段判断方式 0：固定数值 1：浮动范围
        ///</summary>
        [SugarColumn(ColumnName = "intensity_stage_estimate_way")]
        public int IntensityStageEstimateWay { get; set; }

        /// <summary>
        /// 备  注:强度阶段判断值
        ///</summary>
        [SugarColumn(ColumnName = "intensity_stage_estimate_value")]
        public double IntensityStageEstimateValue { get; set; }

        //-----------------------------------------------------------------

        /// <summary>
        /// 备  注:严密阶段压力
        ///</summary>
        [SugarColumn(ColumnName = "rigor_stage_pressure")]
        public double RigorStagePressure { get; set; }

        /// <summary>
        /// 备  注:严密阶段持续时间
        ///</summary>
        [SugarColumn(ColumnName = "rigor_stage_time")]
        public int RigorStageTime { get; set; }

        /// <summary>
        /// 备  注:严密阶段持续时间单位：小时、分钟
        ///</summary>
        [SugarColumn(ColumnName = "rigor_stage_time_unit")]
        public string RigorStageTimeUnit { get; set; } = null!;

        /// <summary>
        /// 备  注:严密阶段判断方式 0：固定数值 1：浮动范围
        ///</summary>
        [SugarColumn(ColumnName = "rigor_stage_estimate_way")]
        public int RigorStageEstimateWay { get; set; }

        /// <summary>
        /// 备  注:严密阶段判断值
        ///</summary>
        [SugarColumn(ColumnName = "rigor_stage_estimate_value")]
        public double RigorStageEstimateValue { get; set; }

        /// <summary>
        /// 备  注:试压阶段数量
        ///</summary>
        [SugarColumn(ColumnName = "stage_count")]
        public int StageCount { get; set; }

        /// <summary>
        /// 备  注:误差范围
        ///</summary>
        [SugarColumn(ColumnName = "error_range")]
        public int ErrorRange { get; set; }

        /// <summary>
        /// 根据模板编号判断是否存在
        /// </summary>
        /// <param name="number"></param>
        /// <returns></returns>
        public static bool RecordExistenceWithNumber(int number)
        {
            Dictionary<string, Object> where = new Dictionary<string, Object>();
            where["number"] = number;
            List<TemplateModel> list = SqlSugarHelper.Inquireable<TemplateModel>(where);
            if (list.Count > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
